package GUI;


import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JButton;
import javax.swing.JRootPane;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JLabel;

import client.ClientConsole;

import java.awt.Font;

/**
 * librerian main menu
 * 
 * @author Maor
 *
 */
public class GUI_LibrarianMenu extends JPanel
{
	private ClientConsole clc;
	private GUI_Catalog catalog;
	private GUI_AddReaderCard rc;
	private GUI_loan loanGui;
	private static GUI_LibrarianMenu lm;
	private GUI_returnBook rb;
	private Gui_ShowReaderCard ec;
	private GUI_Search s;
	
	/**
	 * the constructor, adding all the optional buttons functions for librerian
	 * @param cc client console
	 * @param gl - main  frame window
	 */
	public GUI_LibrarianMenu(final ClientConsole cc, final GUI_LogIn gl)
	{
		setLayout(null);
		this.setSize(700,600);
		clc=cc;
		this.setName("Librarian Menu");
		JButton btnManageCatalog = new JButton("Manage Book Catalog");
		btnManageCatalog.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				catalog=new GUI_Catalog(clc,gl,lm);
				gl.setContentPane(catalog);
			}
		});
		btnManageCatalog.setBounds(23, 49, 167, 23);
		add(btnManageCatalog);
		
		JButton btnReturnBook = new JButton("Return Book");
		btnReturnBook.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				rb=new GUI_returnBook(clc, gl, lm);
				gl.setContentPane(rb);
			}
		});
		btnReturnBook.setBounds(23, 96, 167, 23);
		add(btnReturnBook);
		
		JButton btnAddNewMember = new JButton("Add New Member");
		btnAddNewMember.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				rc=new GUI_AddReaderCard(clc,gl,lm);
				gl.setContentPane(rc);
			}
		});
		btnAddNewMember.setBounds(23, 148, 167, 23);
		add(btnAddNewMember);
		
		JButton btnNewButton = new JButton("Loan Book");
		btnNewButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				loanGui=new GUI_loan(clc,gl,lm);
				gl.setContentPane(loanGui);
			}
		});
		btnNewButton.setBounds(23, 194, 167, 23);
		add(btnNewButton);
		
		JLabel lblChooseOneOf = new JLabel("Choose One Of The Options:");
		lblChooseOneOf.setFont(new Font("Tahoma", Font.BOLD, 13));
		lblChooseOneOf.setBounds(23, 11, 214, 27);
		add(lblChooseOneOf);
		
		lm=this;
		
		JButton btnLogOut = new JButton("Log Out");
		btnLogOut.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				gl.LogOut();
			}
		});
		btnLogOut.setBounds(445, 340, 89, 23);
		add(btnLogOut);
		
		JButton btnEditReadersCards = new JButton("Show Readers Cards");
		btnEditReadersCards.addActionListener(new ActionListener() {
			

			public void actionPerformed(ActionEvent arg0) {
				ec=new Gui_ShowReaderCard(clc,gl,lm);
				gl.setContentPane(ec);
			
			}
		});
		btnEditReadersCards.setBounds(23, 239, 167, 23);
		add(btnEditReadersCards);
		
		JButton btnSearchBook = new JButton("Search Book");
		btnSearchBook.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				s=new GUI_Search(clc,lm);
				gl.setContentPane(s);
			}
		});
		btnSearchBook.setBounds(23, 284, 167, 23);
		add(btnSearchBook);
		
	}
}
